#include<bits/stdc++.h>
using namespace std;
long long t,n,m,l,v,d[100010],va[100010],a[100010],p[1000010],x,cnt,cnt1,flag,anss;
long long chaocar,tnt,flag1;
long double ddd;
char chen[1000010][2];
string s;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>t;
    while(t--)
    {
        cin>>n>>m>>l>>v;s="";
        memset(p,0,sizeof(p));anss=0;chaocar=0;
        flag1=flag=0;tnt=INT_MAX;
        for(int i=1;i<=n;i++)cin>>d[i]>>va[i]>>a[i];
        for(int i=1;i<=m;i++){cin>>x;p[x]=x;cnt=max(cnt,p[i]);}
        cnt1=cnt;
        for(int i=cnt1-1;i>=0;i--){if(p[i]==0)p[i]=cnt;else cnt=p[i];}
        for(int i=1;i<=n;i++)
        {
            if(a[i]>=0){
                ddd=double(sqrt(va[i]*va[i]+2*a[i]*(cnt1-d[i])));
                if(ddd>v)chaocar++;
                flag=1;
            }
            else{
                ddd=sqrt(va[i]*va[i]+2*a[i]*(p[d[i]-d[i]]));
                if(ddd>v){chaocar++;chen[d[i]][0]='(';tnt=min(d[i],tnt);}
                else{
                    ddd=(v*v-va[i]*va[i])*1.0/2.0/a[i];
                    ddd=ddd/1*1;
                    chen[min(d[i]+long(ddd),l)][1]=')';
                    flag1=min(d[i]+long(ddd),max(flag1,l));
                    }

                }
        }
        for(int i=tnt;i<=flag1;i++){
            if(chen[i][1]==')'){s+=')';if(s[s.size()-2]=='(')anss++;}
            if(chen[i][0]=='(')s+='(';
        }
        if(flag==1)anss++;
        cout<<chaocar<<' '<<m-anss<<"\n";
    }
    return 0;
}
